<script lang="ts" setup name="XtxCheckbox">
import { PropType } from 'vue'

defineProps({
  checked: {
    type: Boolean,
    // type: Boolean as PropType<Boolean>,
    default: false
  }
})
// const emit = defineEmits(['update:checked'])
const emit = defineEmits<{
  (e: 'update:checked', value: boolean): void
}>()
</script>

<template>
  <div class="xtx-checkbox" @click="emit('update:checked', !checked)">
    <i class="iconfont icon-checked" v-if="checked"></i>
    <i class="iconfont icon-unchecked" v-else></i>
    <span>
      <slot />
    </span>
  </div>
</template>

<style scoped lang="less">
.xtx-checkbox {
  display: inline-block;
  margin-right: 2px;
  .icon-checked {
    color: @xtxColor;
    ~ span {
      color: @xtxColor;
    }
  }
  i {
    position: relative;
    top: 1px;
  }
  span {
    margin-left: 2px;
  }
}
</style>
